var tplHome = require('../templates/home.string');

// 引用公共方法
var util = require('../utils/fn.js');

SPA.defineView('home', {
  html: tplHome,

  plugins: ['delegated'],

  init: {
    mySwiper: null
  },

  bindActions: {
    'goto.detail': function (e, data) {
      SPA.open('detail', {
        param: {
          data: data
        }
      });
    }
  },

  // bindEvents: {
  //   'show': function () {
  //     this.mySwiper = new Swiper('#home-swiper', {
  //       loop: false,
  //       onSlideChangeStart: function (swiper) {
  //         var index = swiper.activeIndex;
  //         var $lis = $('.m-home nav li');
  //         util.setFocus($lis.eq(index));
  //       }
  //     });
  //   }
  // },

  bindEvents: {
    'show': function () {
      var mySwiper = new Swiper ('.swiper-container', {
        loop: false,
        autoplay:1000,
        // 如果需要分页器
        autoplayDisableOnInteraction:false,
        pagination: '.swiper-pagination',

      })
    }
  }
});
